home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
graphics
/
raymovi2.arc
/
RAYMOVI.DOK
< prev
next >
Wrap
Text File
|
1988-12-21
|
11KB
|
279 lines
RAYMOVI.PRG
RAYMOVI.PRG renders 3-dimensional scenes in a world of reflective and
refractive spheres, using ray tracing techniques. Movies formed from
sequences of frames can be generated, showing reflective balls linked and
bouncing in a gravitational field. They resemble a string of bouncing pearls.
The amount of computation required to produce one ray traced image is
enormous -- on an ST it is measured in hours. To get animated effects,
images must be precomputed in (overnight) batch runs. RAYMOVI provides the
ability to save sequences of images on disk in Degas PI1 format, for later
replay by BLASTRAM.TTP (also included).
RAYMOVI.PRG generates a low resolution approximation of each picture first,
followed by refinement to successively higher resolutions. In this way,
a rough image is seen quickly for (somewhat) interactive debugging. Scenes
can be changed without recompilation of RAYMOVI.PRG -- the size, position,
velocity and optical properties of the balls in the scenes are specified
numerically in the initialization files.
The ray tracing heart of RAYMOVI was taken from net.sources, documented
Fredrich Knauss of University of California, San Diego. I've ported it to
the ST, added animation, (primitive) color, and the various other features
you see here. I place RAYMOVI in the public domain, for non-comercial use only.
RAYMOVI.PRG runs only on a color ST in low resolution. 1 Meg is required
to generate images with resolutions greater than one ray per pixel or for
replay of movies from RAM. Operation with only 512K is possible, but will
produce slightly aliased pictures (one ray per pixel) which can only be
displayed statically, slowly from floppy, or from hard disk (if you have
a disk blaster program).
The rest of this document contains sections entitled Getting Started,
Configuration File Format, and Checkpointing. The sources are available
upon request. With enough interest I could post them.
GETTING STARTED
The screen must be set to low resolution mode before running RAYMOVI.PRG.
Once started, '?' will give help. Keys 'r' reads and 'w' writes the current
screen using the current disk file, whose name is displayed in the upper
left corner of the screen. Key 'e' exits. The average number of rays shot
through each pixel is also displayed in the margin and updated as the
computation develops.
After unpacking RAYMOVI, the first logical thing to do is to start it up
with the configuration file PEARLS. After a few minutes, you'll see
a rough image, with the resolution increasing as you watch. You might
wait an hour or so to get complete development, but if you get bored, hit
the 'r' key. This will read the one pre-computed picture PEARL001.PI1 which
came in the "arc".
Now put RAYMOVI aside until you are willing to dedicate a large chunk of
ST time to make a movie. When you have 10-20 hours free, start RAYMOVI,
again with PEARLS. (Before you start, be sure you have a few hundred K
free on the disk for the images which will be produced.) To view the movie
produced, exit ('e') and start BLASTRAM.TTP, supplying the argument
PEARL in the dialog box. With BLASTRAM running, type '?' for help.
Checkpointing may be used if you wish to add more frames to the movie.
CHECKPOINTING
Since RAYMOVI.PRG runs are so long, checkpointing is important. (Actually
I put it in because my sons rebooted the ST at 3:00 every day after school!).
Thus following the completion of every frame, RAYMOVI saves the current
configuration on the disk so that if the computation of the next frame
is interupted, it may be restarted. The checkpointing information
is written in a file named CHECKPT, in configuration file format. Starting
RAYMOVI with CHECKPT will continue an interupted computation, redoing
only any work which was in progress on the interupted frame.
CONFIGURATION FILE FORMAT
The following section discusses the format of the configuration files,
which specify initial ball positions, velocities and optical properties,
as well as lighting and viewing perspectives, picture resolution, and gravity.
The configuration file name to be used is specified initially with a dialog.
The file is then read line at a time. The character in column 1 specifies the
meaning of the rest of each line. Lines may be up to 200 characters long. Lines
beginning with whitespace are comments. The following other formats are
supported:
- - - 'p' Format: - - -
specifies the physical size and velocity of a ball. There are 7 properties
required for each ball, and they all must be specified on one line in the
following order:
(1) x coordinate of center (2) x velocity
(3) y coordinate (4) y velocity
(5) z coordinate (6) z velocity
(7) radius
Some Notes:
A) In the coordinate system used, Y is upward, X is to the right, and Z
is depth (increasing Z moves farthur away).
B) Balls will bounce off the floor (the plane Y == 0) and an invisible
viewing port (the plane Z==0). Be sure to start them so that the whole
extent of the ball is above the floor and farther away than the
invisible viewing port.
C) If balls start out overlapping, they will stick together.
This turned out to be a serendipitous bug in the bounce algorithm,
and produces the string of pearls from which PEARLS gets its name.
D) The current version is compiled for up to 15 balls maximum.
The first p-format statement in the file defines the "first" ball RAYMOVI
knows about, the second the second and so on. Here are 6 balls which
form an interesting scene:
x vx y vy z vz radius
(1) (2) (3) (4) (5) (6) (7) (see (1)-(7) above)
p 195.0,-20, 130.0, 0, 250.0, 10, 30.0 these are the 4 linked balls:
p 150.0, -5, 100.0, 20, 250.0, 10, 30.0 "
p 105.0, 5, 70.0, 20, 250.0,-20, 30.0 "
p 60.0, 20, 40.0, 0, 250.0,-20, 30.0 "
p 0.0,-10, 300.0, 20, 600.0, 0, 300.0 this is the big ball
p 200.0, 2, 50.0, 5, 60.0, 30, 50.0 a medium size (lone) ball
- - - 'o' Format: - - -
specifies the optical properties of a ball. The following 8 properties
must be put on one line, and in order:
(1) index of refraction
(2) amount of refraction (transparent)
(3) amount of reflection (mirror)
(4) amount of diffuse light (omnidirectional)
(5) amount of ambient light (from light source)
(6) surface color redness
(7) surface color greenness
(8) surface color blueness
Some notes are in order to make realistic objects:
A) All parameters should be positive or zero.
B) Items (2) through (5) should sum to less than 1.0
C) Surface colors (6) through (8) modulate the effect the diffuse and ambient
reflective properties defined by (4) and (5). None should be greater than
1.0.
C) Due to the size of the ST's color palette, surface color items (6)
through (8) are constrained to be patterns corresponding to one of the
following three colors:
white: (6) == (7) == (8) == 1.0
red: (6) == (7) == 1.0, (8) == 0.0
blue: (6) == 0.0, (7) == (8) == 1.0
The i'th 'o' Format line refers to the same ball as the i'th 'p' Format line.
Here are the optical properties for the scene:
(1) (2) (3) (4) (5) (6) (7) (8)
o 0.0, 0.0, 0.3, 0.6, 0.1, 1.0,0.0,0.0 diffuse red, somewhat reflective
o 0.0, 0.0, 0.6, 0.3, 0.1, 1.0,1.0,1.0 reflective, somewhat white
o 0.0, 0.0, 0.9, 0.0, 0.1, 1.0,1.0,1.0 reflective, some ambient
o 0.0, 0.0, 0.0, 0.8, 0.2, 1.0,0.0,0.0 diffuse red, some ambient
o 0.0, 0.0, 0.7, 0.1, 0.2, 1.0,1.0,1.0 reflective and ambient (the big one)
o 1.6, 0.8, 0.0, 0.0, 0.2, 1.0,1.0,1.0 refractive
- - - 'v' Format: - - -
specifies the viewpoint of the display. x, y, and z values are required.
v 215.0, 100.0, -550.0
| | z coordinate of viewpoint
| y coordinate of viewpoint
x coordinate of viewpoint
All rays start at the viewpoint and pass through a rectangle in the Z=0
plane. The rectangle is sized according to the size of the screen -- namely
on a 320x200 low resolution screen, it is defined by 0.0 < X < 320.0 and
0.0 < Y < 200.0. (Actu